#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include <QHttp>
#include <QFile>
#include <QVector>
#include <QPair>
#include <QCloseEvent>
#include "http.h"
#include "updatethread.h"
#include "user_struct.h"
#include "registerdialog.h"
#include "uservector.h"
#include "event_struct.h"
#include "messagebox.h"
#include <QSystemTrayIcon>
#include <phonon>
#include <QMessageBox>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void download();
    void showUserDialog();
    void closeEvent ( QCloseEvent * e );
public slots:
    void writeData(QByteArray array);
    void sendMessage();
    void registerUser(QByteArray array);
    void logout(QByteArray array);
    void sended(QByteArray array);
    void changeUserStatus();
    void bold();
    void italic();
    void underlined();
    void anchorClicked(const QUrl & link);
    void maximazieFromTray(QSystemTrayIcon::ActivationReason reason);
    void dockVisibilityChanged(bool visible);

private:
    Ui::MainWindow *ui;
    UpdateThread *thread;
    Http *http;
    int id;
    userVector userVec;
    user me;
    QVector<event_struct> eventVec;
    MessageBox *messagebox;
    void sendOne();
    QSystemTrayIcon *icon;
    void hideEvent (QHideEvent * event);
    QTimer *m_pHideTimer;
    QTextBlockFormat format;
    bool first;

signals:
    void hideThis();

protected:
    bool event(QEvent *event);

};

#endif // MAINWINDOW_H
